package give.my.money.back;


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

import android.os.Bundle;
import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.ViewGroup.LayoutParams;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;

  
public class MainActivity extends TabActivity {

	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        
        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, Index.class);
        
        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("home").setIndicator(getString(R.string.tab_home_name),
                          res.getDrawable(R.drawable.home_simbol))
                      .setContent(intent);
        tabHost.addTab(spec);
        
        // Do the same for the other tabs
        intent = new Intent().setClass(this, TabDebtorsList.class);
        spec = tabHost.newTabSpec("debtors").setIndicator(getString(R.string.tab_debtors_name),
                          res.getDrawable(R.drawable.dollar_symbol))
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, TabMyDebtsActivity.class);
        spec = tabHost.newTabSpec("my_debts").setIndicator(getString(R.string.tab_my_debts_name),
                          res.getDrawable(R.drawable.dollar_symbol))
                      .setContent(intent);
        tabHost.addTab(spec);
        
       /* intent = new Intent().setClass(this, TabMyServiceActivity.class);
        spec = tabHost.newTabSpec("my_service").setIndicator(getString(R.string.tab_my_service),
                          res.getDrawable(R.drawable.dollar_symbol))
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, MisPreferencias_resultados.class);
        spec = tabHost.newTabSpec("mis_preferencias").setIndicator(getString(R.string.tab_my_preferences),
                          res.getDrawable(R.drawable.dollar_symbol))
                      .setContent(intent);
        tabHost.addTab(spec);*/
        
        tabHost.setCurrentTab(0);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {	
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu, menu);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Inflate the menu; this adds items to the action bar if it is present.
		switch (item.getItemId()){
		case R.id.ayuda:
			Toast.makeText(this, "Has pulsado la ayuda", Toast.LENGTH_SHORT).show();
			//escribirEnFichero();
			break;
		case R.id.acerca_de:
			Toast.makeText(this, "Has pulsado acerca de", Toast.LENGTH_SHORT).show();
			break;
		case R.id.preferencias:
			Intent it = new Intent(this,MisPreferencias.class);
			startActivity(it);
			break;
		} 
		return true;
	}
		
	
}